{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "names= []\n",
    "types = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"data/cars.txt\", \"r\") as f:\n",
    "    j = json.loads(f.read())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame(j['data'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>price</th>\n",
       "      <th>brand</th>\n",
       "      <th>modelNo</th>\n",
       "      <th>type</th>\n",
       "      <th>picture1</th>\n",
       "      <th>picture2</th>\n",
       "      <th>picture3</th>\n",
       "      <th>introduction</th>\n",
       "      <th>twelveMonth</th>\n",
       "      <th>twentyFourMonth</th>\n",
       "      <th>thirtySixMonth</th>\n",
       "      <th>dailyRental</th>\n",
       "      <th>monthlyRental</th>\n",
       "      <th>quarterRental</th>\n",
       "      <th>delFlag</th>\n",
       "      <th>createBy</th>\n",
       "      <th>createDate</th>\n",
       "      <th>updateBy</th>\n",
       "      <th>updateDate</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>165800.0</td>\n",
       "      <td>大众</td>\n",
       "      <td>途岳330TSI</td>\n",
       "      <td>2</td>\n",
       "      <td>https://car3.autoimg.cn/cardfs/product/g3/M01/...</td>\n",
       "      <td>https://car3.autoimg.cn/cardfs/product/g3/M04/...</td>\n",
       "      <td>https://car3.autoimg.cn/cardfs/product/g3/M0B/...</td>\n",
       "      <td>车型级别：紧凑型SUV  车身型式：5门5座SUV  车身尺寸：4453*1841*1632...</td>\n",
       "      <td>13816.67</td>\n",
       "      <td>6908.33</td>\n",
       "      <td>4605.56</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2700.0</td>\n",
       "      <td>24000.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-02-16T06:49:48.000+0000</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-02-16T06:49:48.000+0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>154900.0</td>\n",
       "      <td>雪佛兰</td>\n",
       "      <td>迈锐宝XL</td>\n",
       "      <td>2</td>\n",
       "      <td>https://car3.autoimg.cn/cardfs/product/g30/M01...</td>\n",
       "      <td>https://car2.autoimg.cn/cardfs/product/g30/M0B...</td>\n",
       "      <td>https://car2.autoimg.cn/cardfs/product/g30/M0A...</td>\n",
       "      <td>车型级别：中型车  车身型式：4门5座三厢车  车身尺寸：4933*1854*1472  综...</td>\n",
       "      <td>12908.33</td>\n",
       "      <td>6454.17</td>\n",
       "      <td>4302.78</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2700.0</td>\n",
       "      <td>24000.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-02-16T07:06:42.000+0000</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-02-16T07:06:42.000+0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>286900.0</td>\n",
       "      <td>沃尔沃</td>\n",
       "      <td>S60</td>\n",
       "      <td>2</td>\n",
       "      <td>https://car3.autoimg.cn/cardfs/product/g30/M03...</td>\n",
       "      <td>https://car3.autoimg.cn/cardfs/product/g28/M07...</td>\n",
       "      <td>https://car2.autoimg.cn/cardfs/product/g28/M00...</td>\n",
       "      <td>车型级别：中型车  车身型式：4门5座三厢车  车身尺寸：4761*1850*1437  综...</td>\n",
       "      <td>23908.33</td>\n",
       "      <td>11954.17</td>\n",
       "      <td>7969.44</td>\n",
       "      <td>200.0</td>\n",
       "      <td>5000.0</td>\n",
       "      <td>35000.0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-02-16T07:06:32.000+0000</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-02-16T07:06:32.000+0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id     price brand   modelNo type  \\\n",
       "0   1  165800.0    大众  途岳330TSI    2   \n",
       "1   2  154900.0   雪佛兰     迈锐宝XL    2   \n",
       "2   3  286900.0   沃尔沃       S60    2   \n",
       "\n",
       "                                            picture1  \\\n",
       "0  https://car3.autoimg.cn/cardfs/product/g3/M01/...   \n",
       "1  https://car3.autoimg.cn/cardfs/product/g30/M01...   \n",
       "2  https://car3.autoimg.cn/cardfs/product/g30/M03...   \n",
       "\n",
       "                                            picture2  \\\n",
       "0  https://car3.autoimg.cn/cardfs/product/g3/M04/...   \n",
       "1  https://car2.autoimg.cn/cardfs/product/g30/M0B...   \n",
       "2  https://car3.autoimg.cn/cardfs/product/g28/M07...   \n",
       "\n",
       "                                            picture3  \\\n",
       "0  https://car3.autoimg.cn/cardfs/product/g3/M0B/...   \n",
       "1  https://car2.autoimg.cn/cardfs/product/g30/M0A...   \n",
       "2  https://car2.autoimg.cn/cardfs/product/g28/M00...   \n",
       "\n",
       "                                        introduction  twelveMonth  \\\n",
       "0  车型级别：紧凑型SUV  车身型式：5门5座SUV  车身尺寸：4453*1841*1632...     13816.67   \n",
       "1  车型级别：中型车  车身型式：4门5座三厢车  车身尺寸：4933*1854*1472  综...     12908.33   \n",
       "2  车型级别：中型车  车身型式：4门5座三厢车  车身尺寸：4761*1850*1437  综...     23908.33   \n",
       "\n",
       "   twentyFourMonth  thirtySixMonth  dailyRental  monthlyRental  quarterRental  \\\n",
       "0          6908.33         4605.56        100.0         2700.0        24000.0   \n",
       "1          6454.17         4302.78        100.0         2700.0        24000.0   \n",
       "2         11954.17         7969.44        200.0         5000.0        35000.0   \n",
       "\n",
       "  delFlag  createBy                    createDate  updateBy  \\\n",
       "0       0         1  2020-02-16T06:49:48.000+0000         1   \n",
       "1       0         1  2020-02-16T07:06:42.000+0000         1   \n",
       "2       0         1  2020-02-16T07:06:32.000+0000         1   \n",
       "\n",
       "                     updateDate  \n",
       "0  2020-02-16T06:49:48.000+0000  \n",
       "1  2020-02-16T07:06:42.000+0000  \n",
       "2  2020-02-16T07:06:32.000+0000  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "public String id;\n",
      "public String price;\n",
      "public String brand;\n",
      "public String modelNo;\n",
      "public String type;\n",
      "public String picture1;\n",
      "public String picture2;\n",
      "public String picture3;\n",
      "public String introduction;\n",
      "public String twelveMonth;\n",
      "public String twentyFourMonth;\n",
      "public String thirtySixMonth;\n",
      "public String dailyRental;\n",
      "public String monthlyRental;\n",
      "public String quarterRental;\n",
      "public String delFlag;\n",
      "public String createBy;\n",
      "public String createDate;\n",
      "public String updateBy;\n",
      "public String updateDate;\n"
     ]
    }
   ],
   "source": [
    "for column in df.columns:\n",
    "    print(\"public String {};\".format(column))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "public Integer id;\n",
      "public Integer user_id;\n",
      "public String business_type;\n",
      "public String type_desc;\n",
      "public String title;\n",
      "public String content;\n",
      "public String pic_url;\n",
      "public String del_flag;\n",
      "public Integer create_by;\n",
      "public String create_date;\n",
      "public Integer update_by;\n",
      "public String update_date;\n"
     ]
    }
   ],
   "source": [
    "for i in range(len(names)):\n",
    "    if \"int\" in types[i]:\n",
    "        print(\"public Integer {};\".format(re.findall(\"`(.+)`\", names[i])[0]))\n",
    "    else:\n",
    "        print(\"public String {};\".format(re.findall(\"`(.+)`\", names[i])[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['int(11)',\n",
       " 'int(11)',\n",
       " 'varchar(40)',\n",
       " 'varchar(500)',\n",
       " 'varchar(500)',\n",
       " 'varchar(5000)',\n",
       " 'varchar(500)',\n",
       " 'char(1)',\n",
       " 'int(11)',\n",
       " 'timestamp',\n",
       " 'int(11)',\n",
       " 'timestamp']"
      ]
     },
     "execution_count": 147,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "types"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {},
   "outputs": [],
   "source": [
    "aa = re.findall(\"`(.+)`\",a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "xf_business_config\n",
      "id\n",
      "user_id\n",
      "business_type\n",
      "type_desc\n",
      "title\n",
      "content\n",
      "pic_url\n",
      "del_flag\n",
      "create_by\n",
      "create_date\n",
      "update_by\n",
      "update_date\n",
      "id\n"
     ]
    }
   ],
   "source": [
    "for key in aa:\n",
    "    print(key)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'code': 1,\n",
       " 'msg': 'success',\n",
       " 'data': {'totalCount': 0,\n",
       "  'pageSize': 10,\n",
       "  'totalPage': 0,\n",
       "  'currPage': 1,\n",
       "  'list': []}}"
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "j"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "public String code;\n",
      "public String msg;\n",
      "public String data;\n"
     ]
    }
   ],
   "source": [
    "for key in j.keys():\n",
    "    print(\"public String {};\".format(key))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "public int totalCount;\n",
      "public int pageSize;\n",
      "public int totalPage;\n",
      "public int currPage;\n",
      "public int list;\n"
     ]
    }
   ],
   "source": [
    "for key in j['data'].keys():\n",
    "    print(\"public int {};\".format(key))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [],
   "source": [
    "apis = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"appapi.txt\", \"r\") as f:\n",
    "    for line in f.readlines():\n",
    "        if line.rstrip():\n",
    "            if re.findall(\"\\d、(.+)\", line):\n",
    "                apis.append(re.findall(\"[\\d]+、(.+)\", line))\n",
    "            if re.findall(\"(http:.+)\", line):\n",
    "                apis.append(re.findall(\"(http:.+)\", line))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " 头部 消息 和 banner 图片\n",
      "http://39.108.166.99/app/user/message/get\n",
      "http://39.108.166.99/app/business/config/find\n",
      "转单与订单收益\n",
      "购车租车图片、车型介绍、购买\n",
      "http://39.108.166.99/app/car/config/get\n",
      "http://39.108.166.99/app/car/shortRent/add\n",
      "充值管理到期、充值接口\n",
      "http://39.108.166.99/ app/car/customer/business/find\n",
      "http://39.108.166.99/ app/recharge/add\n",
      "用户名与用户头像\n",
      "http://39.108.166.99/app/user/get\n",
      "消息中心 -> 我的消息\n",
      "http://39.108.166.99/app/user/message/get\n",
      "客服中心\n",
      "账目总览、奖励记录\n",
      "http://39.108.166.99/ app/user/integralLog/find\n",
      "http://39.108.166.99/ app/user/integralLog/counts\n",
      "提成总账\n",
      "奖励总账\n"
     ]
    }
   ],
   "source": [
    "for line in apis:\n",
    "    print(line[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "// 头部 消息 和 banner 图片\n",
      "@POST(\"ioc/app/user/message/get\")\n",
      "Observable<Response<String>> userMessageGet(@Body UserId ui);\n",
      "\n",
      "@POST(\"ioc/app/business/config/find\")\n",
      "Observable<Response<String>> businessConfigFind(@Body UserId ui);\n",
      "\n",
      "//转单与订单收益\n",
      "//购车租车图片、车型介绍、购买\n",
      "@POST(\"ioc/app/car/config/get\")\n",
      "Observable<Response<String>> carConfigGet(@Body UserId ui);\n",
      "\n",
      "@POST(\"ioc/app/car/shortRent/add\")\n",
      "Observable<Response<String>> carShortrentAdd(@Body UserId ui);\n",
      "\n",
      "//充值管理到期、充值接口\n",
      "@POST(\"ioc/app/car/customer/business/find\")\n",
      "Observable<Response<String>> carCustomerBusinessFind(@Body UserId ui);\n",
      "\n",
      "@POST(\"ioc/app/recharge/add\")\n",
      "Observable<Response<String>> rechargeAdd(@Body UserId ui);\n",
      "\n",
      "//用户名与用户头像\n",
      "@POST(\"ioc/app/user/get\")\n",
      "Observable<Response<String>> userGet(@Body UserId ui);\n",
      "\n",
      "//消息中心 -> 我的消息\n",
      "@POST(\"ioc/app/user/message/get\")\n",
      "Observable<Response<String>> userMessageGet(@Body UserId ui);\n",
      "\n",
      "//客服中心\n",
      "//账目总览、奖励记录\n",
      "@POST(\"ioc/app/user/integralLog/find\")\n",
      "Observable<Response<String>> userIntegrallogFind(@Body UserId ui);\n",
      "\n",
      "@POST(\"ioc/app/user/integralLog/counts\")\n",
      "Observable<Response<String>> userIntegrallogCounts(@Body UserId ui);\n",
      "\n",
      "//提成总账\n",
      "//奖励总账\n"
     ]
    }
   ],
   "source": [
    "for line in apis:\n",
    "    if \"http\" in line[0]:\n",
    "        m = re.findall(\"http://39.108.166.99/\\s*app/(.+)\", line[0])[0]\n",
    "        print(\"\"\"@POST(\"ioc/app/{}\")\"\"\".format(m))\n",
    "        methodName = m.split(\"/\")[0] + \"\".join([i.capitalize() for i in m.split(\"/\")[1:]])\n",
    "        print(\"\"\"Observable<Response<String>> {}(@Body UserId ui);\\n\"\"\".format(methodName))\n",
    "    else:\n",
    "        print(\"//{}\".format(line[0]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "//App报警记录: JSON格式传参userId\n",
    "    @POST(\"ioc/app/alarmRecord/oneKeyAlarm\")\n",
    "    Observable<Response<String>> appAlarmRecordOneKeyAlarm(@Body AlarmRecordEntity alarmrecordentity);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [{\n",
    "    \"comment\":\"头部 消息\",\n",
    "    \"path\":\"\",\n",
    "}"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
